<!DOCTYPE HTML>
<html>

<head>

</head>

<body>
    <div id="myDiv">
        <h2>通过 AJAX 改变文本</h2></div>
    <button id="testAjax" type="button">Ajax改变内容</button>
    <script type="text/javascript" src="./js/jquery.min.js"></script>
    <script type="text/javascript">
        $(function() {
            //按钮单击时执行
            $("#testAjax").click(function() {
                //Ajax调用处理
                $.ajax({
                    type: "POST",
                    url: "test.php",
                    data: "name=garfield&age=18",
                    contentType: "application/json;charset=utf-8",
                    success: function(data) {
                        $("#myDiv").html('<h2>' + data + '</h2>');
                    }
                });

            });
        });
    </script>
</body>

</html>
